d9e4d4999351db6cf0ff9ce4339af4473e627643,inputformat/src/test/java/org/zuinnote/hadoop/bitcoin/format/BitcoinFormatHadoopTest.java,BitcoinFormatHadoopTest,readBitcoinRawBlockInputFormatMultiBlock,#,329

Before Change


    Path file = new Path(fileNameBlock);
    FileInputFormat.setInputPaths(job, file);
    BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat();
    format.configure(job);
    InputSplit[] inputSplits = format.getSplits(job,1);
    assertEquals("Only one split generated for multiblock", 1, inputSplits.length);
    	RecordReader<BytesWritable, BytesWritable> reader = format.getRecordReader(inputSplits[0], job, reporter);
	assertNotNull("Format returned  null RecordReader", reader);
	BytesWritable key = new BytesWritable();	
	BytesWritable block = new BytesWritable();

After Change


    String fileName="multiblock.blk";
    String fileNameBlock=classLoader.getResource("testdata/"+fileName).getFile();	
    Path file = new Path(fileNameBlock);
    Job job = Job.getInstance(conf);
    FileInputFormat.setInputPaths(job, file);
    BitcoinRawBlockFileInputFormat format = new BitcoinRawBlockFileInputFormat();
    List<InputSplit> splits = format.getSplits(job);
    TaskAttemptContext context = new TaskAttemptContextImpl(conf, new TaskAttemptID());
    assertEquals("Only one split generated for multiblock", 1, splits.size());
    	RecordReader<BytesWritable, BytesWritable> reader = format.createRecordReader(splits.get(0), context);
	assertNotNull("Format returned  null RecordReader", reader);
	reader.initialize(splits.get(0),context);
	BytesWritable key = new BytesWritable();	
	BytesWritable block = new BytesWritable();
	assertTrue("Input Split for multi block contains the genesis block", reader.nextKeyValue());
	block=reader.getCurrentValue();
	assertEquals("Genesis Block must have size of 293", 293, block.getLength());
	assertTrue("Input Split for block version contains block version 1", reader.nextKeyValue());
	block=reader.getCurrentValue();